home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group99a.txt
/
000205_icon-group-sender _Mon Oct 4 08:42:18 1999.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
3KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id IAA00712
for icon-group-addresses; Mon, 4 Oct 1999 08:42:09 -0700 (MST)
Message-Id: <199910041542.IAA00712@baskerville.CS.Arizona.EDU>
X-Authentication-Warning: agate-ether.berkeley.edu: news set sender to <news> using -f
From: luvisi@andru.sonoma.edu
X-Newsgroups: comp.lang.icon
Subject: Re: A small puzzle
Date: 02 Oct 1999 15:23:04 -0700
To: Steve Wampler <sbw@tapestry.tucson.az.us>
X-Newsreader: Gnus v5.3/Emacs 19.34
To: icon-group@optima.CS.Arizona.EDU
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
Steve Wampler <sbw@tapestry.tucson.az.us> writes:
[snip]
> Write an Icon program to generate the pairings in a round-robin
> tournament. The program should accept the player names as
> command line arguments (see the example below).
[snip]
Here's my attempt:
procedure main()
every gameset := turnament(["a","b","c","d","e"])
do every write((left((pair := !gameset)[1], 5) || left(pair[2], 5)) | "");
every gameset := turnament(["a","b","c","d","e","f"])
do every write((left((pair := !gameset)[1], 5) || left(pair[2], 5)) | "");
end
procedure turnament(people)
local i;
local stationary_player, gameset;
stationary_player := (*people % 2 = 0 & get(people)) | "Buy";
every 1 to *people do {
gameset := [ [ stationary_player, people[*people] ] ];
every gameset |||:= [[people[ i := 1 to (*people - 1) / 2 ], people[-i-1]]];
suspend gameset;
push(people, pull(people));
}
fail;
end
[snip]
> (As an additional challenge, implement an optional -n argument, where
> n is the number of courts - this is as much an exercise in determining
> a reasonable policy for handling the pairing overfow as it is an
> exercise in Icon programming.)
[snip]
hm... it seems the hardest part would be when at the end of a virtual
match, finding the pairs in the next virtual match that don't contain
anybody who's playing in the curent physical match...
Andru
--
--------------------------------------------------------------------------
| Andru Luvisi | http://libweb.sonoma.edu/ |
| Programmer/Analyst | Library Resources Online |
| Ruben Salazar Library |-----------------------------------------|
| Sonoma State University | http://www.belleprovence.com/ |
| luvisi@andru.sonoma.edu | Textile imports from Provence, France |
--------------------------------------------------------------------------